#include<bits/stdc++.h>
using namespace std;
int T,n,a[200010],b[1000010],sum;
int main()
{
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>T;
    while(T--)
    {
        cin>>n;
        sum = 0;
        for(int i = 0;i < n;i++)
        {
            cin>>a[i];
            b[a[i]]++;
        }
        for(int i = 1;i <= 15;i++) if(b[i] >= 2) sum += (b[i] - 1) * i;
        cout<<sum<<endl;
    }
    return 0;
}
